﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Wicresoft.SMS.Common;
using Wicresoft.SMS.Data;
using Wicresoft.SMS.Gateway.Host;

namespace SMS.Gateway.Host.Test
{
    /// <summary>
    /// Summary description for QueryEmailTest
    /// </summary>
    [TestClass]
    public class QueryEmailTest
    {
        
       
        public QueryEmailTest()
        {
            //
            // TODO: Add constructor logic here
            //
        }

        private TestContext testContextInstance;

        /// <summary>
        ///Gets or sets the test context which provides
        ///information about and functionality for the current test run.
        ///</summary>
        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }

        #region Additional test attributes
        //
        // You can use the following additional attributes as you write your tests:
        //
        // Use ClassInitialize to run code before running the first test in the class
        // [ClassInitialize()]
        // public static void MyClassInitialize(TestContext testContext) { }
        //
        // Use ClassCleanup to run code after all tests in a class have run
        // [ClassCleanup()]
        // public static void MyClassCleanup() { }
        //
        // Use TestInitialize to run code before running each test 
        // [TestInitialize()]
        // public void MyTestInitialize() { }
        //
        // Use TestCleanup to run code after each test has run
        // [TestCleanup()]
        // public void MyTestCleanup() { }
        //
        #endregion

        [TestMethod]
        public void TestMethod1()
        {
            IConnectStringProvider csp = new ConnectString();
            IEmailDataAccess eda = new sqlEmailDataAccess(csp);
            List<EmailInfo> list = new List<EmailInfo>();
            EmailInfo ei = new EmailInfo();
            ei.From = "parkerzhou2010@gmail.com";
            ei.Body = "asdasdasd";
            list.Add(ei);
            eda.SendSMSFromEmail(list);
        }

        [TestMethod]
        public void TestEmail()
        {
            ConnectString cs = new ConnectString();
            //using (var dbacc=new Entities(cs.ConnectionString))
            //{
            //    int timespan = 1;
            //    TimeSpan times = new TimeSpan(0, timespan > 60 ? 60 : timespan, 0);
            //    DateTime dt = DateTime.Now;
            //    var msgs = dbacc.Message.Where(m => m.State < 32);
            //    if (msgs != null)
            //    {
            //        foreach (var item in msgs)
            //        {
            //            if ((dt - item.CreateTime) > times)
            //            {
            //                int i = 0;
            //            }
            //        }
            //    }
            //}

            //UserRoleService urs = new UserRoleService(cs);
            //string str1 = urs.GetGetEmailByCSL("dadal");
            //string str2 = urs.GetGetEmailByCSL("ff");
            //string str3 = urs.GetGetEmailByCSL("mengxu");
            //string str4 = urs.GetMobileByCSL("dadal");
            //string str5 = urs.GetMobileByCSL("ff");
            //string str6 = urs.GetMobileByCSL("mengxu");

           StateChecker sc = new StateChecker(cs);
           sc.CheckStates(1, 1, "evansl@wicresoft.com","123213");
           // AppConfigProvider acp = new AppConfigProvider();
           // int i = 0;
        }
    }
}
